﻿using T0yK4T.Data;
using MongoDB;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson;

namespace ToyChat.Server
{
    /// <summary>
    /// "Database Class" - This class contains informations about a user
    /// </summary>
    public class UserInfo : IUserInfo
    {
        /// <summary>
        /// The MongoDB id of this user
        /// </summary>
        [BsonId]
        public ObjectId _id { get; set; }

        /// <summary>
        /// Empty constructor
        /// </summary>
        public UserInfo() { }

        /// <summary>
        /// Initializes a new instance of <see cref="UserInfo"/> and copies values from the specified <see cref="IUserInfo"/> object to the newly created instance
        /// </summary>
        /// <param name="template"></param>
        public UserInfo(IUserInfo template)
        {
            this.Email = template.Email;
            this.Username = template.Username;
            this.PassHash = template.PassHash;
            this.Permissions = template.Permissions;
            this.Username = template.Username;
        }

        /// <summary>
        /// Gets or Sets the username of this user
        /// </summary>
        public string Username
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or Sets the password hash for this user
        /// </summary>
        public string PassHash
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or Sets the email adress of the user
        /// </summary>
        public string Email
        {
            get;
            set;
        }

        /// <summary>
        /// Gets a reference to the <see cref="PermissionFlags"/> of this user
        /// </summary>
        public PermissionFlags Permissions { get; set; }

        /// <summary>
        /// Gets or Sets the nickname of this user (This field is not stored in the database)
        /// </summary>
        [BsonIgnore]
        public string Nickname
        {
            get;
            set;
        }
    }
}